package com.bh.ly.oa.activity;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.BasicHttpContext;

import com.bh.ly.oa.util.Util;

import android.app.Activity;
import android.net.http.AndroidHttpClient;
import android.os.Bundle;
import android.util.Log;

public class TestActivity extends Activity {
	AndroidHttpClient mHttpclient=AndroidHttpClient.newInstance("");
	public void onCreate(Bundle savedInstanceState) {
			new Thread(rTest).start();
	}
	
	   private Runnable rTest=new Runnable() {
	        
	        public void run(){
	            try {
	                BasicHttpContext context=new BasicHttpContext();
	                context.setAttribute(ClientContext.COOKIE_STORE,new BasicCookieStore());
	                HttpPost httppost = new HttpPost("http://220.167.144.154:80/login/login.do");
	                List <BasicNameValuePair> nvps = new ArrayList <BasicNameValuePair>();
	                nvps.add(new BasicNameValuePair("requestData","{\"userCode\":\"200015\",\"password\":\"200015\"}"));
	                httppost.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
	                HttpResponse response=mHttpclient.execute(httppost,context);
	                HttpEntity entity = response.getEntity();
	                Log.v("======================",Util.getBody(entity.getContent()));
	                entity.consumeContent();
	                HttpPost httpget2 = new HttpPost("http://220.167.144.154:80/info/listSupplierCertificate.do");
	                List <BasicNameValuePair> nvps2 = new ArrayList <BasicNameValuePair>();
	                nvps2.add(new BasicNameValuePair("requestData","{\"conditionData\":{\"suppliercode\":\"\",\"suppliercode__tablename\":\"inf_supplier\",\"suppliercode__datatype\":\"char\",\"recorddate__match\":[\"5\",\"6\"],\"suppliercode__datavalue_more\":\"\",\"certificate_type\":\"\",\"certificate_type__tablename\":\"bil_supplier_certificate\",\"certificate_type__datatype\":\"number\",\"certificate_type__match\":\"1\",\"certificate_type__datavalue_more\":\"\",\"enddate\":[\"\",\"\"],\"enddate__tablename\":[\"bil_supplier_certificate\",\"bil_supplier_certificate\"],\"enddate__datatype\":[\"date\",\"date\"],\"enddate__match\":[\"5\",\"6\"],\"enddate__datavalue_more\":[\"\",\"\"],\"recorddate\":[\"\",\"\"],\"recorddate__datatype\":[\"date\",\"date\"],\"recorddate__datavalue_more\":[\"\",\"\"]},\"currentPage\":1}"));
	                httpget2.setEntity(new UrlEncodedFormEntity(nvps2,"utf-8"));
	                HttpResponse response2=mHttpclient.execute(httpget2,context);
	                HttpEntity entity2 = response2.getEntity();
	                //Log.i("kagami", MainActivity.this.toString(entity2.getContent()));
	                Log.v("+++++++++++++++++++++++++++++++++++",Util.getBody(entity2.getContent()));
	                entity2.consumeContent();
	            } catch (Exception e) {
	                e.printStackTrace();
	            }
	        }
	   };
}
